<%@page import="com.bill.common.system.dto.IMessageDTO"%>
<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="com.bill.common.system.service.IIMessageService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
int pages = 1;
if(request.getParameter("pages")!=null && request.getParameter("_pages")!=""){
	pages = Integer.parseInt(request.getParameter("pages"));
}
if(session.getAttribute("password2")==null){
	/* response.sendRedirect( "login2.jsp?pageUrl=user/imessage.jsp");
	return; */
}
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IIMessageService imessageService = (IIMessageService)ac.getBean("imessageService");
IMessageDTO imessageDto = new IMessageDTO();
int rows = 10;imessageDto.setLimit( rows );
int start = ( pages - 1 ) * rows;imessageDto.setStart( start );
imessageDto.setLoginName((String)session.getAttribute("loginName"));
PageDTO pageDTO = imessageService.findPageIMessage(imessageDto,"desc","createTime"); 
if ( pageDTO != null ){ pageDTO.setPage( pages ); pageDTO.setRows( rows );
}
request.setAttribute("pageDTO",pageDTO);
request.setAttribute("pageUrl","imessage.jsp?loginName="+imessageDto.getLoginName());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta charset="UTF-8">
<title><fmt:message key="i18n.emailManage"/>-<fmt:message key="i18n.title"/>  </title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="../index/favicon.png" />
<link href="../skin/skin1/css/subPage.css" rel="stylesheet">
<link rel="stylesheet" href="css/sub_page_main_style.css" />

</head>
<body style="background:#ede3d1;height:800px">
<!-- 主体内容 -->
<div class="account">
	<div class="top">
		<a href="#"><fmt:message key="i18n.moneyManage"/></a> &gt;  <a href="#"><fmt:message key="i18n.message"/></a>
	</div>

    <div class="right" style="margin: 0px;">
    	<div class="listTable lttno">
			
			<table class="table table-bordered table-striped" id="email_table" width="100%">
		   		<thead>
		   			<tr class="color1">
		   				<th><fmt:message key="i18n.titleAndContent"/></th>
		   				<th><fmt:message key="i18n.sendUser"/></th>
		   				<th><fmt:message key="i18n.sendDate"/></th>
		   				<%-- <th><fmt:message key="i18n.status"/></th>
		   				<th>发送/接收</th> --%>
		   			</tr>
		   			
		   		</thead>
		   		<tbody>
		   			
		   			<c:forEach items="${pageDTO.data}" var="data">
		   				<tr>
		   					<td>${data.message}</td>
		   					<td>${data.sendUser}</td>
		   					<td>${data.sendDate}</td>
		   					<%-- <td>${data.status}</td>
		   					<td>${data.mtype}</td> --%>
		   				</tr>
		   			</c:forEach>
		   			
		   			<c:if test="${empty pageDTO.data}">
		   				<tr>
		   					<td colspan="5" align="center"><fmt:message key="i18n.noData"/></td>
		   				</tr>
		   			</c:if>
		   			
		   		</tbody>		        		
		   	</table>
			
			<!-- 分页 start -->
			<div class="page">
			<div id="tr_recommendGrid_pager" class="page_r">
				<ul>
					<li><a href="${pageUrl }&pages=1"><fmt:message key="i18n.firstPage"/></a></li>
					<c:if test="${pageDTO.page > 1}">
						<li><a href="${pageUrl }&pages=${pageDTO.page-1}"><fmt:message key="i18n.upPage"/></a></li>
					</c:if>
					<li><a>${pageDTO.page}/${pageDTO.total}</a></li>
					<c:if test="${pageDTO.page+1<=pageDTO.total}">
						<li><a href="${pageUrl }&pages=${pageDTO.page+1}"><fmt:message key="i18n.nextPage"/></a></li>
					</c:if>
					<li><a href="${pageUrl }&pages=${pageDTO.total}"><fmt:message key="i18n.endPage"/></a></li>
					<li><a><fmt:message key="i18n.total"/>${pageDTO.totalSize}<fmt:message key="i18n.tiao"/></a></li>
				</ul>
			</div>
			</div>
			<!-- 分页 end  -->
			
			<%-- --%>
			<form action="imessage!sendMessage.action" method="post" >
				<input type="hidden" name="imessageDto.sendUser" value="${session.loginName}" />
				<input type="hidden" name="imessageDto.mtype" value="Send" />
				<input type="hidden" name="imessageDto.status" value="Unread" />
				<input type="hidden" name="imessageDto.receiveUser" value="System" />
				<table width="200px;">
					<tr>
						<td><fmt:message key="i18n.MessageContent" /></td>
						<td>
							<textarea name="imessageDto.message" rows="10" cols="100" style="border: 1px solid;" ></textarea>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<input type="submit" style="width: 200px;" value="<fmt:message key="i18n.queding" />"/>
						</td>
					</tr>
				</table>
			</form> 
			
			
    	</div>
    </div>	

		        	
</div>

<script type="text/javascript" src="../scripts/jquery/jquery-1.4.2.min.js"></script>
<script>

$(function(){
    $("#deleteEmail").click(function(){
    	$("#emailForm").submit();
    });
})

</script>

</body>
</html>